package org.darcy.controller.check;

import org.darcy.entity.CheckCollect;
import org.darcy.framework.model.PageData;
import org.darcy.framework.model.PageParam;
import org.darcy.framework.model.R;
import org.darcy.service.check.CheckCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;

@Tag(name = "CheckCollect接口：场调，采样，收样，实验，交付，结算")
@RestController
@RequestMapping(value = "/CheckCollect")
@Slf4j
public class CheckCollectController {

	private final String info_prefix = "[场调，采样，收样，实验，交付，结算模块]";

	@Autowired
	private CheckCollectService checkCollectService;

	@Operation(summary = "场调，采样，收样，实验，交付，结算分页列表")
	@PostMapping(value = "list")
	public R list(@RequestBody PageParam<CheckCollect> param) {
		log.debug("{}-列表数据", info_prefix);
		PageData<CheckCollect> data = checkCollectService.page(param);
		return R.ok().data(data);
	}

	@Operation(summary = "场调，采样，收样，实验，交付，结算详情")
	@GetMapping("/view/{id}")
	public R view(@PathVariable Integer id) {
		log.debug("{}-查看场调，采样，收样，实验，交付，结算信息", info_prefix);
		CheckCollect data = checkCollectService.getById(id);
		return R.ok().data(data);
	}

	@Operation(summary = "根据ID删除场调，采样，收样，实验，交付，结算")
	@PostMapping("/del/{id}")
	public R del(@PathVariable Integer id) {
		log.debug("{}-根据ID删除", info_prefix, id);
		checkCollectService.delete(id);
		return R.ok("删除成功");
	}

	@Operation(summary = "更新场调，采样，收样，实验，交付，结算")
	@PostMapping("update")
	public R update(@RequestBody CheckCollect record) {
		log.debug("{}-保存信息: {}", info_prefix, record);
		checkCollectService.updateFlow(record);
		return R.ok("更新成功");
	}

	@Operation(summary = "查看场调，采样，收样，实验，交付，结算属性")
	@GetMapping("/model")
	public CheckCollect model() {
		return null;
	}

}
